
<!DOCTYPE html>
<html lang="en" class="loading">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>大二学生的第一次web面试 - Bittersweet.的博客</title>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="google" content="notranslate" />
    <meta name="keywords" content="bittersweet,"> 
    <meta name="description" content="我在学校里做的一些项目，以及遇到的问题的解决方法，希望为有需要的人提供帮助,一、前言：
本着试一试的想法，在众多大牛学长们灌输的前端实习越早越好的观念，大二下期的我，开始了投递自己的简历，boss直聘上投了60多家，沟通的有10个，邀请我去面试的只有两家，本章就是我去面试的,"> 
    <meta name="author" content="Bittersweet.(姚亮)"> 
    <link rel="alternative" href="atom.xml" title="Bittersweet.的博客" type="application/atom+xml"> 
    <link rel="icon" href="/Bittersweet/img/favicon.ico"> 
    
    <meta name="twitter:image:src" content="https://bangdream.moe/img/ident.png"/>
    <meta name="twitter:creator" content="@yourtwitteridhere"/>
    <meta name="twitter:card" content="summary_large_image"/>
    <meta name="twitter:title" content="大二学生的第一次web面试 - Bittersweet.的博客"/>
    <meta name="twitter:description" content="我在学校里做的一些项目，以及遇到的问题的解决方法，希望为有需要的人提供帮助,一、前言：
本着试一试的想法，在众多大牛学长们灌输的前端实习越早越好的观念，大二下期的我，开始了投递自己的简历，boss直聘上投了60多家，沟通的有10个，邀请我去面试的只有两家，本章就是我去面试的,"/>
    <meta property="og:image" content="https://bangdream.moe/img/ident.png"/>
    <meta property="og:image:alt" content="我在学校里做的一些项目，以及遇到的问题的解决方法，希望为有需要的人提供帮助,一、前言：
本着试一试的想法，在众多大牛学长们灌输的前端实习越早越好的观念，大二下期的我，开始了投递自己的简历，boss直聘上投了60多家，沟通的有10个，邀请我去面试的只有两家，本章就是我去面试的,"/>
    <meta property="og:image:width" content="1200"/>
    <meta property="og:image:height" content="600"/>
    <meta property="og:site_name" content="Bittersweet.的博客"/>
    <meta property="og:type" content="object"/>
    <meta property="og:title" content="大二学生的第一次web面试 - Bittersweet.的博客"/>
    <meta property="og:description" content="我在学校里做的一些项目，以及遇到的问题的解决方法，希望为有需要的人提供帮助,一、前言：
本着试一试的想法，在众多大牛学长们灌输的前端实习越早越好的观念，大二下期的我，开始了投递自己的简历，boss直聘上投了60多家，沟通的有10个，邀请我去面试的只有两家，本章就是我去面试的,"/>
    
<link rel="stylesheet" href="/Bittersweet/css/diaspora.css">

    <script>window.searchDbPath = "/Bittersweet/search.xml";</script>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro&display=swap" rel="stylesheet">
<meta name="generator" content="Hexo 6.3.0"></head>

<body class="loading">
    <span id="config-title" style="display:none">Bittersweet.的博客</span>
    <div id="loader"></div>
    <div id="single">
    <div id="top" style="display: block;">
    <div class="bar" style="width: 0;"></div>
    <a class="iconfont icon-home image-icon" href="javascript:;" data-url="http://gitee.com/yao-liang-8848"></a>
    <div title="播放/暂停" class="iconfont icon-play"></div>
    <h3 class="subtitle">大二学生的第一次web面试</h3>
    <div class="social">
        <div>
            <div class="share">
                <a title="获取二维码" class="iconfont icon-scan" href="javascript:;"></a>
            </div>
            <div id="qr"></div>
        </div>
    </div>
    <div class="scrollbar"></div>
</div>

    <div class="section">
        <div class="article">
    <div class='main'>
        <h1 class="title">大二学生的第一次web面试</h1>
        <div class="stuff">
            <span>三月 27, 2023</span>
            
  <ul class="post-tags-list" itemprop="keywords"><li class="post-tags-list-item"><a class="post-tags-list-link" href="/Bittersweet/tags/Vue/" rel="tag">Vue</a></li><li class="post-tags-list-item"><a class="post-tags-list-link" href="/Bittersweet/tags/js/" rel="tag">js</a></li><li class="post-tags-list-item"><a class="post-tags-list-link" href="/Bittersweet/tags/web/" rel="tag">web</a></li><li class="post-tags-list-item"><a class="post-tags-list-link" href="/Bittersweet/tags/%E9%9D%A2%E8%AF%95/" rel="tag">面试</a></li></ul>


        </div>
        <div class="content markdown">
            <h1 id="一、前言："><a href="#一、前言：" class="headerlink" title="一、前言："></a>一、前言：</h1><blockquote>
<p>本着试一试的想法，在众多大牛学长们灌输的前端实习越早越好的观念，大二下期的我，开始了投递自己的简历，boss直聘上投了60多家，沟通的有10个，邀请我去面试的只有两家，本章就是我去面试的经历与讲解，如果你最近也在面试，那我认为这篇文章可能会对你有所帮助</p>
</blockquote>
<h2 id="本次面试的流程，与我的面试情况"><a href="#本次面试的流程，与我的面试情况" class="headerlink" title="本次面试的流程，与我的面试情况"></a>本次面试的流程，与我的面试情况</h2><blockquote>
<p>首先，面试题如下：</p>
<p>1.说一说<strong>防抖和节流</strong>，有什么应用场景</p>
<p>2.<strong>ajax</strong>的实现原理，有什么特性，优缺点，怎么解决<strong>跨域问题</strong></p>
<p>3.for each函数的实现原理，跟for有什么区别</p>
<p>4.实现一条0.5px的线</p>
<p>5.写一个函数，实现将字符串前后的空格除去</p>
<p>6.为什么.vue2响应式使用<strong>Object.defineProperty()<strong>而vue3使用</strong>proxy代理</strong></p>
<p>7.vue中的双向数据绑定与微信小程序的双向数据绑定的区别</p>
<p>感觉题目还是比较基础的，但是我对于第三个for each的实现上没有去了解过，然后最后一个微信小程序的双向绑定也没有了解过，其他都答的还不错。</p>
<p>我的面试过程还是比较曲折的，吐槽一下成都孵化园，我找e座找了半天，原来在某家火锅旁边，怎么那么多超市火锅什么的在那里啊</p>
</blockquote>
<h1 id="二、分析本次面试"><a href="#二、分析本次面试" class="headerlink" title="二、分析本次面试"></a>二、分析本次面试</h1><p>我的评价是大二有实力的兄弟最好投大厂，普通小厂基本上只要时间充足，马上就能来上班的那种</p>
<h2 id="上述面试题的解决方案如下："><a href="#上述面试题的解决方案如下：" class="headerlink" title="上述面试题的解决方案如下："></a>上述面试题的解决方案如下：</h2><h3 id="1-防抖和节流："><a href="#1-防抖和节流：" class="headerlink" title="1.防抖和节流："></a>1.防抖和节流：</h3><blockquote>
<p>防抖：应用场景主要在我们搜索框的输入上面，当我们多次打字输入的时候，每一次他都促发了对应的函数，而防抖要做的就是每一次触发只执行最后一次（定时器规定时间内）</p>
</blockquote>
<pre class="line-numbers language-javascript" data-language="javascript"><code class="language-javascript"><span class="token comment">// 防抖是在多次点击中，只执行最后一次，前面的点击都会被取消</span>
<span class="token keyword">function</span> <span class="token function">debounce</span><span class="token punctuation">(</span><span class="token parameter">fn<span class="token punctuation">,</span> del</span><span class="token punctuation">)</span> <span class="token punctuation">&#123;</span>
    <span class="token keyword">let</span> timer <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>

    <span class="token keyword">return</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">&#123;</span>
        <span class="token function">clearTimeout</span><span class="token punctuation">(</span>timer<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//清楚定时器</span>
        <span class="token keyword">let</span> context <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">;</span>
        <span class="token keyword">let</span> args <span class="token operator">=</span> arguments<span class="token punctuation">;</span>

        timer <span class="token operator">=</span> <span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">&#123;</span>
            <span class="token function">fn</span><span class="token punctuation">.</span><span class="token function">apply</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> args<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">&#125;</span><span class="token punctuation">,</span> del<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<blockquote>
<p>节流：应用场景主要是浏览器的滚动，函数完成前的重复多次点击当中，只执行第一次点击，在第一次点击完成前，后面的点击都会无效</p>
</blockquote>
<pre class="line-numbers language-javascript" data-language="javascript"><code class="language-javascript"><span class="token keyword">function</span> <span class="token function">throttle</span><span class="token punctuation">(</span><span class="token parameter">fn<span class="token punctuation">,</span> del</span><span class="token punctuation">)</span><span class="token punctuation">&#123;</span>
    <span class="token keyword">let</span> last<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">&#123;</span>
        <span class="token keyword">let</span> now<span class="token operator">=</span>Date<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span>now<span class="token operator">-</span>last<span class="token operator">></span>del<span class="token punctuation">)</span><span class="token punctuation">&#123;</span>
            <span class="token function">fn</span><span class="token punctuation">.</span><span class="token function">apply</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> arguments<span class="token punctuation">)</span><span class="token punctuation">;</span>
            last<span class="token operator">=</span>now<span class="token punctuation">;</span>
        <span class="token punctuation">&#125;</span>
    <span class="token punctuation">&#125;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>



<h3 id="2-1-Ajax实现原理与特性还有缺点："><a href="#2-1-Ajax实现原理与特性还有缺点：" class="headerlink" title="2.1 Ajax实现原理与特性还有缺点："></a>2.1 Ajax实现原理与特性还有缺点：</h3><p>我在面试中是这样子回答的：ajax主要用来发送请求，他的特性是异步刷新，也就意味着你某个地方获取后端数据呈现后，不会让整个页面跟着刷新，他的核心机制是XMLHttpReques。</p>
<p>缺点就是会受同源策略的影响，不能跨域请求。</p>
<p>回答的还是比较简陋，很多地方没有说清楚，下面是正紧回答：</p>
<blockquote>
<p>原理：Ajax的原理简单来说通过XmlHttpRequest对象来向服务器发送异步请求，从服务器获得数据，然后用JavaScript来操作DOM而更新页面。这其中最关键的一步就是从服务器获得请求数据。要清楚这个过程和原理，我们必须对 XMLHttpRequest有所了解。</p>
<p>XMLHttpRequest是ajax的核心机制，它是在IE5中首先引入的，是一种支持异步请求的技术。简单的说，也就是JavaScript可以及时向服务器提出请求和处理响应，而不阻塞用户。达到无刷新的效果</p>
<p>特性：在不需要重新刷新页面的情况下，Ajax 通过异步请求加载后台数据，并在网页上呈现出来</p>
<p>应用场景：常见运用场景有表单验证是否登入成功、百度搜索下拉框提示和快递单号查询等等。</p>
</blockquote>
<h4 id="2-2-如何解决跨域问题"><a href="#2-2-如何解决跨域问题" class="headerlink" title="2.2 如何解决跨域问题"></a>2.2 如何解决跨域问题</h4><blockquote>
<p>跨域问题是啥？</p>
<p><strong>跨域</strong>，是指浏览器不能执行其他网站的脚本。它是由浏览器的<code>同源策略</code>造成的。<br>       <strong>同源策略</strong>,是浏览器对 JavaScript 实施的安全限制，只要<code>协议、域名、端口</code>有任何一个不同，都被当作是不同的域。<br>       <strong>跨域原理</strong>，即是通过各种方式，<code>避开浏览器的安全限制</code>。</p>
</blockquote>
<h5 id="方案1，JSONP"><a href="#方案1，JSONP" class="headerlink" title="方案1，JSONP:"></a>方案1，JSONP:</h5><p>ajax 请求受同源策略影响，不允许进行跨域请求，而 script 标签 src 属性中的链 接却可以访问跨域的 js 脚本，利用这个特性，服务端不再返回 JSON 格式的数据，而是 返回一段调用某个函数的 js 代码，在 src 中进行了调用，这样实现了跨域。</p>
<p>步骤：</p>
<ol>
<li><p>去创建一个script标签</p>
</li>
<li><p>script的src属性设置接口地址</p>
</li>
<li><p>接口参数，必须要带一个自定义函数名，要不然后台无法返回数据</p>
</li>
<li><p>通过定义函数名去接受返回的数据</p>
<blockquote>
<p>缺点：JSON 只支持 get，因为 script 标签只能使用 get 请求； JSONP 需要后端配合返回指定格式的数据</p>
</blockquote>
</li>
</ol>
<h5 id="方案2，配置代理："><a href="#方案2，配置代理：" class="headerlink" title="方案2，配置代理："></a>方案2，配置代理：</h5><p>像vue或react这种脚手架，跨域通过配置代理来解决</p>
<h5 id="方案3，让后端在请求头上加信息什么的"><a href="#方案3，让后端在请求头上加信息什么的" class="headerlink" title="方案3，让后端在请求头上加信息什么的"></a>方案3，让后端在请求头上加信息什么的</h5><h3 id="3-for-each的实现原理，与for有什么区别："><a href="#3-for-each的实现原理，与for有什么区别：" class="headerlink" title="3.for each的实现原理，与for有什么区别："></a>3.for each的实现原理，与for有什么区别：</h3><pre class="line-numbers language-javascript" data-language="javascript"><code class="language-javascript"><span class="token class-name">Array</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span><span class="token function-variable function">newForEach</span> <span class="token operator">=</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token parameter">fn</span><span class="token punctuation">)</span> <span class="token punctuation">&#123;</span>
    <span class="token keyword">let</span> i
    <span class="token keyword">for</span><span class="token punctuation">(</span>i<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span> i<span class="token operator">&lt;</span><span class="token keyword">this</span><span class="token punctuation">.</span>length<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span><span class="token punctuation">&#123;</span>
       <span class="token keyword">if</span><span class="token punctuation">(</span>i <span class="token keyword">in</span> <span class="token keyword">this</span><span class="token punctuation">)</span><span class="token punctuation">&#123;</span> 
     	  <span class="token function">fn</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">,</span> i<span class="token punctuation">)</span>
       <span class="token punctuation">&#125;</span>
    <span class="token punctuation">&#125;</span>      
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<p>其实还是用了for，前者其实算是后者的语法糖</p>
<blockquote>
<h6 id="foreach与for循环的明显差别在于foreach循环时循环对象（数组、集合）被锁定，不能对循环对象中的内容进行增删改操作。"><a href="#foreach与for循环的明显差别在于foreach循环时循环对象（数组、集合）被锁定，不能对循环对象中的内容进行增删改操作。" class="headerlink" title="foreach与for循环的明显差别在于foreach循环时循环对象（数组、集合）被锁定，不能对循环对象中的内容进行增删改操作。"></a>foreach与for循环的明显差别在于foreach循环时循环对象（数组、集合）被锁定，不能对循环对象中的内容进行增删改操作。</h6></blockquote>
<h3 id="4-实现一条0-5px的线："><a href="#4-实现一条0-5px的线：" class="headerlink" title="4.实现一条0.5px的线："></a>4.实现一条0.5px的线：</h3><pre class="line-numbers language-markup" data-language="markup"><code class="language-markup"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>line<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>style</span><span class="token punctuation">></span></span><span class="token style"><span class="token language-css">
    <span class="token selector">*</span><span class="token punctuation">&#123;</span>
        <span class="token property">margin</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
        <span class="token property">padding</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
<span class="token selector">.line</span><span class="token punctuation">&#123;</span>
    <span class="token property">margin-top</span><span class="token punctuation">:</span> 30px<span class="token punctuation">;</span>
    <span class="token property">width</span><span class="token punctuation">:</span> 100%<span class="token punctuation">;</span>
    <span class="token property">height</span><span class="token punctuation">:</span> 0.5px<span class="token punctuation">;</span>
    <span class="token property">background-color</span><span class="token punctuation">:</span> #9c118c<span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>
</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>style</span><span class="token punctuation">></span></span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h3 id="5-写一个函数，字符串前后的空格除去："><a href="#5-写一个函数，字符串前后的空格除去：" class="headerlink" title="5.写一个函数，字符串前后的空格除去："></a>5.写一个函数，字符串前后的空格除去：</h3><pre class="line-numbers language-javascript" data-language="javascript"><code class="language-javascript"><span class="token comment">// 方法1 正则校验</span>
<span class="token keyword">let</span> str <span class="token operator">=</span><span class="token string">' xiao ming '</span>
<span class="token keyword">const</span> <span class="token function-variable function">newStr</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token parameter">str</span><span class="token punctuation">)</span><span class="token operator">=></span><span class="token punctuation">&#123;</span>
    <span class="token keyword">let</span> reg<span class="token operator">=</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^\s+|\s+$</span><span class="token regex-delimiter">/</span><span class="token regex-flags">g</span></span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> str<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span>reg<span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>
  <span class="token keyword">let</span> ans1<span class="token operator">=</span><span class="token function">newStr</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>ans1<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//'xiao ming'</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<pre class="line-numbers language-javascript" data-language="javascript"><code class="language-javascript"><span class="token comment">// 方法2 直接用trim函数</span>
<span class="token keyword">const</span> <span class="token function-variable function">trim</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token parameter">str</span><span class="token punctuation">)</span> <span class="token operator">=></span><span class="token punctuation">&#123;</span>
    <span class="token keyword">return</span> str<span class="token punctuation">.</span><span class="token function">trim</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
<span class="token keyword">let</span> ans2<span class="token operator">=</span><span class="token function">trim</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>ans2<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//'xiao ming'</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<blockquote>
<p>菜鸟教程：$.trim()  函数用于去除字符串两端的空白字符。</p>
</blockquote>
<h3 id="6-VUE2与VUE3响应式的区别："><a href="#6-VUE2与VUE3响应式的区别：" class="headerlink" title="6.VUE2与VUE3响应式的区别："></a>6.VUE2与VUE3响应式的区别：</h3><p>详情可以看我的这一篇<a target="_blank" rel="noopener" href="http://yao-liang-8848.gitee.io/Bittersweet/2023/03/10/%E2%80%9C%E6%B5%85%E8%B0%88Vue2%E4%B8%8EVue3%E5%93%8D%E5%BA%94%E5%BC%8F%E7%9A%84%E5%8C%BA%E5%88%AB%E2%80%9D/">文章</a></p>
<h3 id="7-vue中的双向数据绑定与微信小程序中的区别"><a href="#7-vue中的双向数据绑定与微信小程序中的区别" class="headerlink" title="7.vue中的双向数据绑定与微信小程序中的区别"></a>7.vue中的双向数据绑定与微信小程序中的区别</h3><p>在面试之前我只对vue中的有过了解，而微信小程序中的双向数据绑定，我回来后就问了下chatgpt，下面是他的答案</p>
<blockquote>
<p>1.Vue 中的双向数据绑定是通过 <code>v-model</code> 实现的，它可以实现数据的双向绑定，即当用户在输入框中输入内容时，数据模型中的值也会随之改变；反之，当数据模型中的值发生变化时，输入框中展示的值也会自动更新。</p>
<p>2.微信小程序中的双向数据绑定与 Vue 中略有不同。在小程序中，需要使用 <code>bindinput</code> 事件和 <code>value</code> 属性来实现双向数据绑定。当用户在输入框中输入内容时，<code>bindinput</code> 事件会触发并将输入框中的值传递给相应的数据模型属性；当数据模型属性发生变化时，对应的 <code>value</code> 属性也会自动更新。</p>
<p>3.因此，在 Vue 中实现双向数据绑定更加简单明了，而在微信小程序中则需要手动处理 <code>bindinput</code> 事件和 <code>value</code> 属性的关系。</p>
</blockquote>
<p>Chatgpt神中神，用来辅助开发是真的爽</p>
<h1 id="End："><a href="#End：" class="headerlink" title="End："></a>End：</h1><blockquote>
<p>感谢你的观看，本人也只是个大二的学生，如果有问题请指正，如果你觉得这篇文章对你有帮助，请点赞收藏。</p>
<p>有大佬路过的话，希望可以分享一下面试经验这些，谢谢啦！</p>
</blockquote>

            <!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->
            <audio id="audio" loop="1" preload="auto" controls="controls" data-autoplay="false">
                <source type="audio/mpeg" src="">
            </audio>
            
                <ul id="audio-list" style="display:none">
                    
                        
                            <li title="0" data-url="http://link.hhtjim.com/163/425570952.mp3"></li>
                        
                    
                        
                            <li title="1" data-url="http://link.hhtjim.com/163/425570952.mp3"></li>
                        
                    
                </ul>
            
        </div>
        
        
    <div id="gitalk-container" class="comment link"
		data-enable="false"
        data-ae="false"
        data-ci=""
        data-cs=""
        data-r=""
        data-o=""
        data-a=""
        data-d="false"
    >查看评论</div>


    </div>
    
        <div class="side">
            <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%80%E3%80%81%E5%89%8D%E8%A8%80%EF%BC%9A"><span class="toc-number">1.</span> <span class="toc-text">一、前言：</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%9C%AC%E6%AC%A1%E9%9D%A2%E8%AF%95%E7%9A%84%E6%B5%81%E7%A8%8B%EF%BC%8C%E4%B8%8E%E6%88%91%E7%9A%84%E9%9D%A2%E8%AF%95%E6%83%85%E5%86%B5"><span class="toc-number">1.1.</span> <span class="toc-text">本次面试的流程，与我的面试情况</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BA%8C%E3%80%81%E5%88%86%E6%9E%90%E6%9C%AC%E6%AC%A1%E9%9D%A2%E8%AF%95"><span class="toc-number">2.</span> <span class="toc-text">二、分析本次面试</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%8A%E8%BF%B0%E9%9D%A2%E8%AF%95%E9%A2%98%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E5%A6%82%E4%B8%8B%EF%BC%9A"><span class="toc-number">2.1.</span> <span class="toc-text">上述面试题的解决方案如下：</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-%E9%98%B2%E6%8A%96%E5%92%8C%E8%8A%82%E6%B5%81%EF%BC%9A"><span class="toc-number">2.1.1.</span> <span class="toc-text">1.防抖和节流：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-1-Ajax%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86%E4%B8%8E%E7%89%B9%E6%80%A7%E8%BF%98%E6%9C%89%E7%BC%BA%E7%82%B9%EF%BC%9A"><span class="toc-number">2.1.2.</span> <span class="toc-text">2.1 Ajax实现原理与特性还有缺点：</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-%E5%A6%82%E4%BD%95%E8%A7%A3%E5%86%B3%E8%B7%A8%E5%9F%9F%E9%97%AE%E9%A2%98"><span class="toc-number">2.1.2.1.</span> <span class="toc-text">2.2 如何解决跨域问题</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%96%B9%E6%A1%881%EF%BC%8CJSONP"><span class="toc-number">2.1.2.1.1.</span> <span class="toc-text">方案1，JSONP:</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%96%B9%E6%A1%882%EF%BC%8C%E9%85%8D%E7%BD%AE%E4%BB%A3%E7%90%86%EF%BC%9A"><span class="toc-number">2.1.2.1.2.</span> <span class="toc-text">方案2，配置代理：</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%96%B9%E6%A1%883%EF%BC%8C%E8%AE%A9%E5%90%8E%E7%AB%AF%E5%9C%A8%E8%AF%B7%E6%B1%82%E5%A4%B4%E4%B8%8A%E5%8A%A0%E4%BF%A1%E6%81%AF%E4%BB%80%E4%B9%88%E7%9A%84"><span class="toc-number">2.1.2.1.3.</span> <span class="toc-text">方案3，让后端在请求头上加信息什么的</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-for-each%E7%9A%84%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86%EF%BC%8C%E4%B8%8Efor%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%9A"><span class="toc-number">2.1.3.</span> <span class="toc-text">3.for each的实现原理，与for有什么区别：</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#foreach%E4%B8%8Efor%E5%BE%AA%E7%8E%AF%E7%9A%84%E6%98%8E%E6%98%BE%E5%B7%AE%E5%88%AB%E5%9C%A8%E4%BA%8Eforeach%E5%BE%AA%E7%8E%AF%E6%97%B6%E5%BE%AA%E7%8E%AF%E5%AF%B9%E8%B1%A1%EF%BC%88%E6%95%B0%E7%BB%84%E3%80%81%E9%9B%86%E5%90%88%EF%BC%89%E8%A2%AB%E9%94%81%E5%AE%9A%EF%BC%8C%E4%B8%8D%E8%83%BD%E5%AF%B9%E5%BE%AA%E7%8E%AF%E5%AF%B9%E8%B1%A1%E4%B8%AD%E7%9A%84%E5%86%85%E5%AE%B9%E8%BF%9B%E8%A1%8C%E5%A2%9E%E5%88%A0%E6%94%B9%E6%93%8D%E4%BD%9C%E3%80%82"><span class="toc-number">2.1.3.0.0.1.</span> <span class="toc-text">foreach与for循环的明显差别在于foreach循环时循环对象（数组、集合）被锁定，不能对循环对象中的内容进行增删改操作。</span></a></li></ol></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-%E5%AE%9E%E7%8E%B0%E4%B8%80%E6%9D%A10-5px%E7%9A%84%E7%BA%BF%EF%BC%9A"><span class="toc-number">2.1.4.</span> <span class="toc-text">4.实现一条0.5px的线：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5-%E5%86%99%E4%B8%80%E4%B8%AA%E5%87%BD%E6%95%B0%EF%BC%8C%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%89%8D%E5%90%8E%E7%9A%84%E7%A9%BA%E6%A0%BC%E9%99%A4%E5%8E%BB%EF%BC%9A"><span class="toc-number">2.1.5.</span> <span class="toc-text">5.写一个函数，字符串前后的空格除去：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#6-VUE2%E4%B8%8EVUE3%E5%93%8D%E5%BA%94%E5%BC%8F%E7%9A%84%E5%8C%BA%E5%88%AB%EF%BC%9A"><span class="toc-number">2.1.6.</span> <span class="toc-text">6.VUE2与VUE3响应式的区别：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#7-vue%E4%B8%AD%E7%9A%84%E5%8F%8C%E5%90%91%E6%95%B0%E6%8D%AE%E7%BB%91%E5%AE%9A%E4%B8%8E%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F%E4%B8%AD%E7%9A%84%E5%8C%BA%E5%88%AB"><span class="toc-number">2.1.7.</span> <span class="toc-text">7.vue中的双向数据绑定与微信小程序中的区别</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#End%EF%BC%9A"><span class="toc-number">3.</span> <span class="toc-text">End：</span></a></li></ol>
        </div>
    
</div>


    </div>
</div>
<script src="/Bittersweet/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/Bittersweet/live2dw/assets/assets/koharu.model.json"},"display":{"position":"right","width":200,"height":400},"mobile":{"show":true},"react":{"opacity":0.8},"log":false});</script></body>


<script src="//lib.baomitu.com/jquery/1.8.3/jquery.min.js"></script>
<script src="/Bittersweet/js/plugin.js"></script>
<script src="/Bittersweet/js/typed.js"></script>
<script src="/Bittersweet/js/diaspora.js"></script>


<link rel="stylesheet" href="/Bittersweet/photoswipe/photoswipe.css">
<link rel="stylesheet" href="/Bittersweet/photoswipe/default-skin/default-skin.css">


<script src="/Bittersweet/photoswipe/photoswipe.min.js"></script>
<script src="/Bittersweet/photoswipe/photoswipe-ui-default.min.js"></script>


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>
    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">
        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">
                <!--  Controls are self-explanatory. Order can be changed. -->
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <button class="pswp__button pswp__button--share" title="Share"></button>
                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>
            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>



<script type="text/x-mathjax-config">
    MathJax.Hub.Config({"HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"], linebreaks: { automatic:true }, EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50) },
        tex2jax: { inlineMath: [ ["$", "$"], ["\\(","\\)"] ], processEscapes: true, ignoreClass: "tex2jax_ignore|dno",skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']},
        TeX: {  noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } }, Macros: { href: "{}" } },
        messageStyle: "none"
    });
</script>
<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>

<script async type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML">
</script>




</html>
